//
//  StatusCellBottomView.swift
//  MicroBlog
//
//  Created by  NorthCity on 15/11/9.
//  Copyright © 2015年  NorthCity. All rights reserved.
//

import UIKit

class StatusCellBottomView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setUpUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
//    MARK: - 懒加载控件
    /// 转发
    private var fowardButton:UIButton = UIButton(
        title: " 转发",
        fontSize: 12,
        color: .lightGrayColor(),
        imageName: "timeline_icon_retweet")
    /// 评论
    private var commentButton:UIButton = UIButton(
        title: " 评论",
        fontSize: 12,
        color: .lightGrayColor(),
        imageName: "timeline_icon_comment")
    /// 点赞
    private var likeButton:UIButton = UIButton(
        title: " 赞",
        fontSize: 12,
        color: .lightGrayColor(),
        imageName: "timeline_icon_unlike")
    /// 分割线视图函数
    private func spView()->UIView{
        let v = UIView()
        v.backgroundColor = UIColor.redColor()
        return v
    }
}
//    MARK: - 设置界面
extension StatusCellBottomView{
    func setUpUI(){
//        0 背景颜色
        backgroundColor = UIColor(white: 0.9, alpha: 1)
//        1 添加控件
        addSubview(fowardButton)
        addSubview(commentButton)
        addSubview(likeButton)

//        2 设置自动布局
        fowardButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
        }

        commentButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(fowardButton.snp_top)
            make.left.equalTo(fowardButton.snp_right)
            make.width.equalTo(fowardButton.snp_width)
            make.height.equalTo(fowardButton.snp_height)
        }

            likeButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(commentButton.snp_top)
            make.left.equalTo(commentButton.snp_right)
            make.width.equalTo(commentButton.snp_width)
            make.height.equalTo(commentButton.snp_height)
            
            make.right.equalTo(self.snp_right)
        }
        //        分割线
        let sp1 = spView()
        addSubview(sp1)
        let sp2 = spView()
        addSubview(sp2)
        sp1.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(fowardButton.snp_centerY)
            make.left.equalTo(fowardButton.snp_right)
            make.width.equalTo(0.5)
            make.height.equalTo(fowardButton.snp_height).multipliedBy(0.4)
        }
        
        sp2.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(fowardButton.snp_centerY)
            make.left.equalTo(commentButton.snp_right)
            make.width.equalTo(sp1.snp_width)
            make.height.equalTo(commentButton.snp_height).multipliedBy(0.4)
        }
    }
}
